package cn.smart.epic.core.log.factory;

import cn.smart.epic.common.constant.state.LogSucceed;
import cn.smart.epic.common.constant.state.LogType;
import cn.smart.epic.common.persistence.model.LoginLog;
import cn.smart.epic.common.persistence.model.OperationLog;

import java.util.Date;

/**
 * @Auther Uncle_Z
 * @date 2017/9/29 22:46
 * @Email:2545375@qq.com
 * @Descrition 日志对象创建工厂
 * @since 1.0
 */

public class LogFactory {

    /**
     *
     * 创建操作日志
     *
     * @param
     * @return
     * @Auther Z.B
     * @date 2017/9/29 22:53
     */
    public static OperationLog createOperationLog(LogType logType, Integer userId, String bussinessName,
                                                  String clazzName, String methodName, String msg, LogSucceed logSucceed){
        OperationLog operationLog=new OperationLog();
        operationLog.setLogtype(logType.getMessage());
        operationLog.setLogname(bussinessName);
        operationLog.setUserid(userId);
        operationLog.setClassname(clazzName);
        operationLog.setMethod(methodName);
        operationLog.setCreatetime(new Date());
        operationLog.setMessage(msg);
        operationLog.setSucceed(logSucceed.getMessage());
        return operationLog;
    }

    /**
     *
     * 创建登录日志
     *
     * @param
     * @return
     * @Auther Z.B
     * @date 2017/9/29 22:56
     */
    public static LoginLog createLoginLog(LogType logType, Integer userId, String msg, String ip){
        LoginLog loginLog = new LoginLog();
        loginLog.setLogname(logType.getMessage());
        loginLog.setUserid(userId);
        loginLog.setCreatetime(new Date());
        loginLog.setSucceed(LogSucceed.SUCCESS.getMessage());
        loginLog.setIp(ip);
        loginLog.setMessage(msg);
        return loginLog;
    }
}
